package cm.day08;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Test4 {
    public static void main(String[] args) {
        Map<Integer,String> map=new HashMap<>();
        map.put(1,"张三");
        map.put(2,"李四");
        map.put(3,"王五");
        System.out.println(map.size());
        //键找值
        Set<Integer> keys=map.keySet();
        //遍历
        for (Integer key : keys) {
            String value=map.get(key);
            System.out.println("Key="+key+",Value="+value);
        }
        Set<Map.Entry<Integer, String>> entries=map.entrySet();
        for (Map.Entry<Integer, String> entry : entries) {
            Integer key= entry.getKey();
            String value= entry.getValue();

            System.out.println("Key="+key+",Value="+value);
        }
        //获取键为1：
        System.out.println(map.get(1));
        //获取10
        System.out.println(map.get(10));
        //判断集合是否有10，
        if (map.containsKey(1)){
            System.out.println(map.get(10));
        }
        //删除集合
        System.out.println(map.remove(1));
    }
}
